
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:yp/helper.dart';

import 'logic.dart';
import 'state.dart';

class AllEvaluationPage extends StatefulWidget {

  @override
  State<StatefulWidget> createState() {
    return _AllEvaluationPage();
  }
}

class _AllEvaluationPage extends State<AllEvaluationPage> {
  final AllEvaluationLogic logic = Get.put(AllEvaluationLogic());
  final AllEvaluationState state = Get.find<AllEvaluationLogic>().state;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        elevation: setWidth(1),
        backgroundColor: Colors.white,
        title: Text(
          '全部评价',
          style: TextStyle(
            color: Colors.black,
            fontSize: 17,
          ),
        ),
        iconTheme: IconThemeData(
          color: Colors.black, //修改颜色
        ),
      ),
      body: GetBuilder<AllEvaluationLogic>(
        builder: (logic) {
          return Container(
            color: Color(0xffF5F5F5),
            child: ListView.separated(
              scrollDirection: Axis.vertical,
              itemBuilder: (context, index) {
                return _evaluateItemWidget(index: index);
              },
              separatorBuilder: (context, index) {
                return SizedBox(
                  height: setWidth(20),
                );
              },
              itemCount: 3,
            ),
          );
        },
      ),
    );
  }

  // 评价 item
  Widget _evaluateItemWidget({int index,}) {

    return Container(
      color: Colors.white,
      padding: EdgeInsets.only(
        left: setWidth(20),
        top: setWidth(44),
        right: setWidth(20),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              ClipRRect(
                borderRadius: BorderRadius.circular(setWidth(38)),
                child: Image.asset(
                  'assets/images/avatar.png',
                  width: setWidth(76),
                  height: setWidth(76),
                  fit: BoxFit.cover,
                ),
              ),
              SizedBox(
                width: setWidth(16),
              ),
              Expanded(
                child: Container(
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Text(
                        '路人甲的停滞',
                        maxLines: 1,
                        overflow: TextOverflow.ellipsis,
                        style: TextStyle(
                          color: Color(0xff222222),
                          fontSize: 14,
                        ),
                      ),
                      SizedBox(
                        height: setWidth(10),
                      ),
                      Wrap(
                        spacing: setWidth(6),
                        children: ['', '', '', '', ''].asMap().map((key, value) {
                          return MapEntry(
                            key,
                            Row(
                              mainAxisSize: MainAxisSize.min,
                              children: [
                                Container(
                                  child: Image.asset(
                                    'assets/images/fivePointedStar_image.png',
                                    width: setWidth(22),
                                    height: setWidth(22),
                                    fit: BoxFit.cover,
                                  ),
                                ),
                              ],
                            ),
                          );
                        }).values.toList(),
                      ),
                    ],
                  ),
                ),
              ),
              SizedBox(
                width: setWidth(16),
              ),
              Text(
                '2019年7月6日 12:23:16',
                style: TextStyle(
                  color: Color(0xffaaaaaa),
                  fontSize: 11,
                ),
              ),
            ],
          ),
          Padding(
            padding: EdgeInsets.only(
              top: setWidth(28),
              bottom: setWidth(20),
            ),
            child: Text(
              '夏天来了，天气最近跟干燥，皮肤也比以前干了好多，所以最近我 变得勤快多了，每天睡觉前都不偷懒，认真进行每个护肤步骤啦啦 小嘎有三个月大概噶使用彩色牙膏测试干啥呀成功使用啊',
              style: TextStyle(
                color: Color(0xff222222),
                fontSize: 12,
              ),
            ),
          ),
          Wrap(
            spacing: setWidth(20),
            runSpacing: setWidth(20),
            children: ['', '', ''].asMap().map((key, value) {
              return MapEntry(
                key,
                Row(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    Container(
                      child: Image.asset(
                        'assets/images/avatar.png',
                        width: setWidth(140),
                        height: setWidth(140),
                        fit: BoxFit.cover,
                      ),
                    ),
                  ],
                ),
              );
            }).values.toList(),
          ),
          Padding(
            padding: EdgeInsets.symmetric(vertical: setWidth(20)),
            child: Container(
              color: Color(0xfff7f7f7),
              padding: EdgeInsets.all(setWidth(26)),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text(
                        '客服回复：',
                        style: TextStyle(
                          color: Color(0xff222222),
                          fontSize: 14,
                        ),
                      ),
                      Text(
                        '2019年12月21日 13:21:21',
                        style: TextStyle(
                          color: Color(0xffB3B3B3),
                          fontSize: 11,
                        ),
                      ),
                    ],
                  ),
                  Text(
                    '感谢您对本产品的大力支持和厚爱，希望您的皮肤越来越光洁丝滑，祝您购物愉快么么哒～',
                    style: TextStyle(
                      color: Color(0xff222222),
                      fontSize: 12,
                    ),
                  ),
                ],
              ),
            ),
          ),
          Text(
            '购买25天后追评',
            style: TextStyle(
              color: Color(0xffEA5504),
              fontSize: 12,
            ),
          ),
          Padding(
            padding: EdgeInsets.only(
              top: setWidth(10),
              bottom: setWidth(20),
            ),
            child: Text(
              '值得拥有，5星没错，还是这个效果好，质量有保证，物流很快，大 家可以放心下单购买～',
              style: TextStyle(
                color: Color(0xff222222),
                fontSize: 12,
              ),
            ),
          ),
          Wrap(
            spacing: setWidth(20),
            runSpacing: setWidth(20),
            children: ['', ''].asMap().map((key, value) {
              return MapEntry(
                key,
                Row(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    Container(
                      child: Image.asset(
                        'assets/images/avatar.png',
                        width: setWidth(140),
                        height: setWidth(140),
                        fit: BoxFit.cover,
                      ),
                    ),
                  ],
                ),
              );
            }).values.toList(),
          ),
          Padding(
            padding: EdgeInsets.only(
              top: setWidth(20),
              bottom: setWidth(26),
            ),
            child: Container(
              color: Color(0xfff7f7f7),
              padding: EdgeInsets.all(setWidth(26)),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text(
                        '客服回复：',
                        style: TextStyle(
                          color: Color(0xff222222),
                          fontSize: 14,
                        ),
                      ),
                      Text(
                        '刚刚',
                        style: TextStyle(
                          color: Color(0xffAAAAAA),
                          fontSize: 11,
                        ),
                      ),
                    ],
                  ),
                  Text(
                    '感谢您对本产品的大力支持和厚爱，希望您的皮肤越来越光洁丝滑，祝您购物愉快么么哒～',
                    style: TextStyle(
                      color: Color(0xff222222),
                      fontSize: 12,
                    ),
                  ),
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }

}